<?php
/**
 * app端启动页设置
 *
 *
 *
 ** 本系统由好商城 shop w w i.com提供
 */



defined('In33hao') or exit('Access Invalid!');
class mb_advControl extends SystemControl{
    public function __construct(){
        parent::__construct();
//         Language::read('mobile');
    }

    public function indexOp(){
        $model_setting = Model('setting');
        $mobile_adv = $model_setting->getListSetting('mb_adv');
        $mobile_adv_img = $mobile_adv['mb_adv_img'];
        if (chksubmit()){
            if ($_FILES['mb_adv_img']['tmp_name'] != ''){
                $upload = new UploadFile();
                $upload->set('default_dir',ATTACH_MOBILE.'/app');

                $result = $upload->upfile('mb_adv_img');
                if ($result){
                    $update_array['mb_adv_img'] = $upload->file_name;
                }else {
                    showMessage($upload->error);
                }
            }
            $update_array['mb_adv_link'] = $_POST['mb_adv_link'];
            $result = $model_setting->updateSetting($update_array);
            if ($result){
                if ($mobile_adv_img){
                    @unlink(BASE_ROOT_PATH.DS.DIR_UPLOAD.DS.ATTACH_MOBILE.'/app/'.$mobile_adv_img);
                }
                showMessage(Language::get('nc_common_save_succ'));
            }else {
                showMessage(Language::get('nc_common_save_fail'));
            }
        }
        Tpl::output('mb_adv_img',$mobile_adv_img);
        Tpl::output('mb_adv_link',$mobile_adv['mb_adv_link']);
        Tpl::setDirquna('mobile');
Tpl::showpage('mb_adv.index');
    }
}
